home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / GNUSUTIL.ZIP / lib / safe-lstat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-17  |  1.8 KB  |  72 lines

  1. /* safe-lstat.h -- EINTR-safe interface to lstat
  2.    Copyright (C) 1994 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.    
  18. /* Written by Jim Meyering <meyering@comco.com>.  */
  19.  
  20. #ifndef _safe_lstat_h_
  21. #define _safe_lstat_h_ 1
  22.  
  23. /* NOTE: you must include the following headers (in the listed order)
  24.    before this one: <sys/types.h>, <sys/stat.h>.  */
  25.  
  26. #if !defined(S_ISLNK) && defined(S_IFLNK)
  27. #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  28. #endif
  29.  
  30. #ifndef S_ISLNK
  31. #include "safe-stat.h"
  32. #define SAFE_LSTAT SAFE_STAT
  33. #define safe_lstat safe_stat
  34. #else
  35.  
  36. #include <errno.h>
  37.  
  38. #ifndef errno
  39. extern int errno;
  40. #endif
  41.  
  42. #ifndef __GNUC__
  43. #define __inline /* empty */
  44. #endif
  45.  
  46. /* On some systems, lstat can return EINTR.  */
  47.  
  48. #ifndef EINTR
  49. # define SAFE_LSTAT(name, buf) lstat (name, buf)
  50. #else
  51. # ifndef __static
  52. #   define __static static
  53. # endif
  54. # define SAFE_LSTAT(name, buf) safe_lstat (name, buf)
  55. __static __inline int
  56. safe_lstat (name, buf)
  57.      const char *name;
  58.      struct stat *buf;
  59. {
  60.   int ret;
  61.  
  62.   do
  63.     ret = lstat (name, buf);
  64.   while (ret < 0 && errno == EINTR);
  65.  
  66.   return ret;
  67. }
  68. #endif
  69.  
  70. #endif /* S_ISLNK */
  71. #endif /* _safe_lstat_h_ */
  72.